// 添加统一的返回结果方法
module.exports = function (req, res, next) {
	res.sendResult = function (obj) {
		var fmt = req.query.fmt ? req.query.fmt : "rest";
		if (fmt == "rest") {
			res.json(
				{
					"data": obj.data,
					"message": obj.message,
					"code": obj.code,
				});
		}
	};
	//自定义格式
	res.sendResultAto = function (data, code, message) {
		var fmt = req.query.fmt ? req.query.fmt : "rest";
		if (fmt == "rest") {
			res.json(
				{
					data,
					"message": message,
					"code": code,
				});
		}
	};
	next();
}

module.exports.resExtra = (data, code = 200, message = '操作成功！') => {
	return { data, code, message }
}

